
import 'package:core/extension/extension_map.dart';

extension ExtensionList on List {
  // String toStringWith({String splitUnit = '、', String def = '无'}) {
  //   String str = toString();
  //   return str.substring(1, str.length - 1).replaceAll(', ', splitUnit).dealData(def: def);
  // }

  bool get elementIsNull => this is List<Null>;

  bool get elementIsNotNull => !elementIsNull;

  String listToStructureString({int indentation = 2}) {
    String result = "";
    String indentationStr = " " * indentation;
    if (true) {
      result += "$indentationStr[";
      forEach((value) {
        if (value is Map) {
          var temp = value.mapToStructureString(indentation: indentation + 2);
          result += "\n$indentationStr\"$temp\",";
        } else if (value is List) {
          result += value.listToStructureString(indentation: indentation + 2);
        } else {
          result += "\n$indentationStr\"$value\",";
        }
      });
      result = result.substring(0, result.length - 1);
      result += "\n$indentationStr]";
    }

    return result;
  }
}
